//
//  SEShareController.m
//  kuaiyi
//
//  Created by Alphts on 16/7/5.
//  Copyright © 2016年 Alphts. All rights reserved.
//

#import "SEShareController.h"
#import "SEShareView.h"


@interface SEShareController ()<UITableViewDelegate>

@property (nonatomic, strong) NSURL *url;

@end

@implementation SEShareController

- (void)viewDidLoad {
    [super viewDidLoad];

    [self setupUI];

}

-(void)setupUI{
    
    UIView *shadowView = [[UIView alloc] initWithFrame:self.view.frame];
    
    shadowView.backgroundColor = [UIColor lightGrayColor];
    
    [self.view addSubview:shadowView];
    
    SEShareView *shareView = [[SEShareView alloc] initWithFrame:CGRectZero];
    
    shareView.delegate = self;
    
    [shadowView addSubview:shareView];
    
    [shareView makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(0);
        make.right.offset(0);
        make.bottom.offset(0);
        make.height.offset(365);
    }];
    
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    NSURL *url = [NSURL URLWithString:@"http://www.baidu.com"];
    
        UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"确认分享"message:nil preferredStyle:UIAlertControllerStyleAlert];
    
        UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
    
            [[UIApplication sharedApplication] openURL:url];
        }];
    
        UIAlertAction *cancleAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
    
        }];
    
        [alert addAction:sureAction];
    
        [alert addAction:cancleAction];
    
        [self presentViewController:alert animated:YES completion:nil];
    
}



@end
